package coder812.User.controller;

import coder812.User.entity.User;
import coder812.User.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by 来自北海的风 on 2017/8/12.
 */
@Controller
@RequestMapping("Test")
public class LoginController01 {
    private UserService userServiceImpl;

    @Autowired
    public LoginController01(UserService userServiceImpl){
        this.userServiceImpl=userServiceImpl;
    }

    @RequestMapping
    public String ToLogin(){
        return "login";
    }
    @RequestMapping("/check")
    @ResponseBody
    public String Login(HttpServletRequest request){
        String name=request.getParameter("username");
        String pssword=request.getParameter("password");

        User user=userServiceImpl.selectByUsername("name");

        if(user!=null){
            if(pssword.equals(user.getPassword())){
                return "login_succ";
            }else{
                return "login_fail";
            }

        }else {
            return "login_fail";
        }



    }
}
